//
//  DCHttpTools.swift
//  Secret
//
//  Created by point on 16/8/12.
//  Copyright © 2016年 dacai. All rights reserved.
//

import AFNetworking

public enum RequestType : String {
    case GET = "GET"
    case POST = "POST"
}

class DCHttpTools: AFHTTPSessionManager {
    
    var domin = "http://192.168.0.109/basic/web/index.php?"
    
    
    static let shareInstance : DCHttpTools = {
        let tools = DCHttpTools()
        tools.requestSerializer.timeoutInterval = 4
        tools.responseSerializer.acceptableContentTypes?.insert("text/html")
        tools.responseSerializer.acceptableContentTypes?.insert("text/plain")
        return tools
    }()
}

//// MARK:- 封装请求方法
//extension DCHttpTools {
//    
//    func request(methodType : RequestType, urlString : String, parameters : [String : AnyObject],progressing : @escaping (_ result : AnyObject?)->(),finished : @escaping (_ result : AnyObject?, _ error : NSError?) -> ()) {
//        
//        let url = domin+urlString
//        // 1.定义进度回调闭包
//        let progressCallBack = { (progress : AnyObject?) -> Void in
//            progressing(progress)
//           
//        }
//        
//        // 2.定义成功的回调闭包
//        let successCallBack = { (task : URLSessionDataTask, result : AnyObject?) -> Void in
//            finished(result as? [String : AnyObject] as AnyObject , nil)
//        }
//        
//        // 3.定义失败的回调闭包
//        let failureCallBack = { (task : URLSessionDataTask?, error : NSError) -> Void in
//            finished(nil, error)
//        }
//        
////        if methodType == .GET {
////        GET(url, parameters: parameters, progress:progressCallBack, success: successCallBack, failure: failureCallBack)
////        }else {
////        POST(url, parameters: parameters, progress:progressCallBack, success: successCallBack, failure: failureCallBack)
////        }
//    }
//    
//}

